package com.macrohard.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.macrohard.admin.service.TeacherService;
import com.macrohard.mapper.domain.Teacher;
import com.macrohard.mapper.mapper.TeacherMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 27371
* @description 针对表【teacher】的数据库操作Service实现
* @createDate 2022-07-14 12:32:00
*/
@Service
@RequiredArgsConstructor
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher>
    implements TeacherService {

	private final TeacherMapper teacherMapper;

	@Override
	@Cacheable("teacher-names")
	public List<String> getAllName() {
		return teacherMapper.getTName();
	}

	@Override
	public List<Teacher> getAllNameAndTeacherid() {
		return teacherMapper.getTNameAndTTeacherid();
	}

	@Override
	@CachePut("teacher-names")
	public int add(Teacher teacher) {
		return teacherMapper.insert(teacher);
	}

	@Override
	@CachePut("teacher-names")
	public int modify(Teacher teacher) {
		return teacherMapper.updateById(teacher);
	}

	@Override
	@CachePut("teacher-names")
	public int removeOne(int id) {
		return teacherMapper.deleteById(id);
	}
}




